package tests;

import java.io.BufferedInputStream;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import junit.framework.TestCase;
import lz77.CompressedData;
import lz77.Lz77;

public class Lz77Test extends TestCase {

	protected void setUp() throws Exception {
		super.setUp();
	}

	public void testLz77() throws IOException {
		CompressedData cd = Lz77.compress("test_infile", (char) 128);
		Lz77.decompress(cd, "test_outfile");

		InputStream inf = new BufferedInputStream(new FileInputStream(
				"test_infile"));
		InputStream outf = new BufferedInputStream(new FileInputStream(
				"test_infile"));
		
		while (true) {
			int in, out;
			in = inf.read();
			out = outf.read();
			assertEquals(in, out);
			if (in == -1) {
				break;
			}
		}
		inf.close();
		outf.close();
	}
}
